﻿using System;
using Rogan.Utility.Extensions;
using Rogan.Utility.Resource;

namespace Rogan.Utility.Common
{
    /// <summary>
    /// Guard
    /// </summary>
    public static class Guard
    {
        /// <summary>
        /// Is Not Null
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="parameterName"></param>
        public static void IsNotNull(object parameter, string parameterName)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(parameterName, TextResource.CannotBeNull.FormatWith(new object[]
				{
					parameterName
				}));
            }
        }
        /// <summary>
        /// Is Not Null Or Empty
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="parameterName"></param>
        public static void IsNotNullOrEmpty(string parameter, string parameterName)
        {
            if (string.IsNullOrEmpty(parameter ?? string.Empty))
            {
                throw new ArgumentException(TextResource.CannotBeNullOrEmpty.FormatWith(new object[]
				{
					parameterName
				}));
            }
        }

        /// <summary>
        /// Check
        /// </summary>
        /// <param name="result"></param>
        /// <param name="message"></param>
        public static void Check(bool result, string message)
        {
            if (!result)
            {
                throw new ArgumentException(message);
            }
        }
    }
}
